function [mean,sigma] = getMeanAndSigmaFromCDF(cdf)

%cdf is the cumulative distribution function
%y will spline it, then diff it, and that will be the pdf.
%then I will compute mean and sigma from the pdf

[rows,columns] = size(cdf);

%limits on the results
xMin = cdf(1,1);
xMax = cdf(rows,1);

%step size
eps = (xMax-xMin)/(rows-1);

%x grid to spline
xx = xMin:eps:xMax;

%splines
yy = spline(cdf(:,1),cdf(:,2),xx);

%now, get the pdf
pdf = diff(yy);
%and add it a final value, because diff, cut it off
pdf(rows) = 0;

plot(xx,pdf,'.k')

mean = xx*pdf';

%compute second moment of the distribution <f(x)^2>
for i=1:length(pdf)
    xSquared(i) = xx(i)*xx(i);
end

x2 = xSquared * pdf';

sigma = sqrt(x2-mean*mean);

%plot(xx,pdf,'.:k',cdf(:,1),cdf(:,2),':b');

